package com.NetSunWeiQin.chapter11.calc;


import javax.naming.Context;
import javax.naming.InitialContext;

/**
 * @author : wushikai
 * <p>
 * date : 2022-04-25
 * 在rmiregistry注册表中注册远程对象，向客户端提供远程对象服务
 */
public class ClientTest {



    public static void main(String args[]) {
        try {
            Context namingContext = new InitialContext();  // 初始化命名内容
            RemoteInterface RmObj = (RemoteInterface) namingContext.lookup("rmi://localhost:8848/RemoteObj");  //获得远程对象的存根对象
            System.out.println(RmObj.doSomething());//通过远程对象，调用doSomething方法
            System.out.println("远程服务器计算结果为：" + RmObj.Calculate(90, 2));
        } catch (Exception e) {
            System.out.println("ERROR " + e.getMessage());
            e.printStackTrace();
        }
    }
}
